package org.scratchcrew.services;

import org.scratchcrew.domain.User;
import org.springframework.transaction.annotation.Transactional;

/**
 * Interface for operations supported for Users.
 */
public interface UserService extends EntityService<User> {

	/**
	 * Creates a user and persists it to the database. The password should be
	 * digested.
	 * 
	 * @param userName
	 * @param password
	 */
	@Transactional
	public User create(String userName, String password);

	/**
	 * Deletes user form the database.
	 * 
	 * @param id
	 *            id of the user to be deleted.
	 */
	@Transactional
	void delete(Long userId);
	
	@Transactional(readOnly=true)
	public User findByName(String userName);
	
	@Transactional(readOnly=true)
	public User findByNameAndPass(String userName, String pass);
	
	@Transactional(readOnly=true)
	public boolean exists(String userName);
}
